from utils.page_base import PageBase

from selenium.webdriver.common.by import By

#登录页 页面类
class PageLogin(PageBase):
    url="/simple/login"
    loc_zanhao=By.NAME,"login_info"
    loc_pwd=By.XPATH,"//input[@name='password']"
    loc_login=By.CSS_SELECTOR,"input[value='登录'][type='submit']"
    loc_error=By.CSS_SELECTOR,"div.prompt"


    def __init__(self,driver,base_url):
        PageBase.__init__(self,driver,base_url)

    #打开当前页面
    def openUrl(self):
        self.open(PageLogin.url)

    #输入账号
    def input_zanhao(self,zanhao):
        self.input(PageLogin.loc_zanhao,zanhao)

    #输入密码
    def input_pwd(self,pwd):
        self.input(PageLogin.loc_pwd,pwd)

    #点击登录按钮
    def click_login(self):
        self.click(PageLogin.loc_login)

    #获取div标签(错误提示)的文本内容
    def getDivText(self):
        return self.getEleText(PageLogin.loc_error)

    #获取密码框的class属性的值
    def getPwdClassAttr(self):
        return self.getEleAttr(PageLogin.loc_pwd,"class")

    # 获取账号筐的class属性的值
    def getZanhaoClassAttr(self):
        return self.getEleAttr(PageLogin.loc_zanhao, "class")

